package com.study_day01.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.study_day01.entiry.Drug;
import com.study_day01.mapper.DrugMapper;
import com.study_day01.service.DrugService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.availability.LivenessState;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DrugServiceImpl implements DrugService {


    @Autowired
    private DrugMapper drugMapper;

    @Override
    public List<Drug> getAllDrugs() {

        return drugMapper.selectList(null);
    }

    @Override
    public Drug getDrugById(Integer id) {
        return drugMapper.selectById(id);
    }

    @Override
    public List<Drug> getDrugsByName(String drName) {

        return drugMapper.selectList(Wrappers.<Drug>lambdaQuery().like(Drug::getDrName, drName));
    }
}